package com.training.java.core.homework05;

public class Interface1Demo {

	public static void main(String[] args) {
		Transaction transaction;

		// Customer transaction:
		System.out.println("Customer transaction:");
		System.out.println("---------------------");

		Person customer = new Customer(100, 100);
		transaction = new Transaction(customer);

		if(customer instanceof Person)
		{
			System.out.println("customer is instance of Person");
		}
		if(customer instanceof Customer)
		{
			System.out.println("customer is instance of Customer");
		}
		
		System.out.println("");
		System.out.println("Before transaction, customer's cash = " + customer.getCashOfIndividual());
		System.out.println("Before transaction, vendor's cash   = " + customer.getCashOfOrganization());

		transaction.doTransaction(30);
		
		System.out.println("At end of transaction, customer's cash = " + customer.getCashOfIndividual());
		System.out.println("At end of transaction, vendor's cash   = " + customer.getCashOfOrganization());
		
		// Student transaction:
		System.out.println("");
		System.out.println("Student transaction:");
		System.out.println("--------------------");

		Person student = new Student(100, 100);
		transaction = new Transaction(student);

		if(student instanceof Person)
		{
			System.out.println("student is instance of Person");
		}
		if(student instanceof Student)
		{
			System.out.println("student is instance of Student");
		}

		System.out.println("");
		System.out.println("Before transaction, student's cash  = " + student.getCashOfIndividual());
		System.out.println("Before transaction, school's cash   = " + student.getCashOfOrganization());

		transaction.doTransaction(40);
		
		System.out.println("At end of transaction, student's cash  = " + student.getCashOfIndividual());
		System.out.println("At end of transaction, school's cash   = " + student.getCashOfOrganization());
		
		// Employee transaction:
		System.out.println("");
		System.out.println("Employee transaction:");
		System.out.println("---------------------");
		
		Person employee = new Employee(100, 100, 1000);
		transaction = new Transaction(employee);

		if(employee instanceof Person)
		{
			System.out.println("customer is instance of Person");
		}
		if(employee instanceof Employee)
		{
			System.out.println("customer is instance of Employee");
		}
		
		System.out.println("");
		System.out.println("Before transaction, employee's cash  = " + employee.getCashOfIndividual());
		System.out.println("Before transaction, company's cash   = " + employee.getCashOfOrganization());
		System.out.println("Before transaction, uncle Sam's cash = " + ((Employee) employee).getCashOfIRS());

		transaction.doTransaction(40);
		
		System.out.println("At end of transaction, employee's cash  = " + employee.getCashOfIndividual());
		System.out.println("At end of transaction, school's cash    = " + employee.getCashOfOrganization());
		System.out.println("At end of transaction, uncle Sam's cash = " + ((Employee) employee).getCashOfIRS());
	}
}
